package com.example.controller;

import com.example.entity.Gradle;
import com.example.entity.Student;
import com.example.entity.User;
import com.example.service.SendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：liukai
 * @date ：Created in 2021/9/7 2:50 下午
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
public class SendController {

    @Autowired
    private SendService service;

    @PostMapping("/rocket/sendUserInfo")
    public String send(@RequestBody User user) {
        return service.sendMessage(user.toString());
    }

    @GetMapping("/rocket/send")
    public String send1() {
        return service.sendMessage("send消息");
    }

    @GetMapping("/rocket/sendMany/{num}")
    public String send2(@PathVariable("num") int num) {

        for (int i = 0; i < num; i++) {
            new Thread(() -> {
                service.sendMessage("send消息");
            }).start();
        }

        return "发送成功";
    }

//    @RequestMapping(value = "/send", method = RequestMethod.GET)
//    public String send(String msg) {
//        service.send(msg);
//        return "字符串消息发送成功!";
//    }
//
//    @RequestMapping(value = "/sendWithTags", method = RequestMethod.GET)
//    public String sendWithTags(String msg) {
//        service.sendWithTags(msg, "tagStr");
//        return "带tag字符串消息发送成功!";
//    }
//
//    @RequestMapping(value = "/sendObject", method = RequestMethod.GET)
//    public String sendObject(int index) {
//        service.sendObject(new Gradle("语文", 100), "tagObj");
//        return "Object对象消息发送成功!";
//    }

}
